package com.op.studyingliteapp.activity;

import java.util.List;

import android.app.ActionBar;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.ImageView;
import android.widget.TextView;

import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.op.studyingliteapp.R;
import com.op.studyingliteapp.bean.CourseNotifBean;
import com.op.studyingliteapp.common.Common;
import com.op.studyingliteapp.database.dao.CourseNotifDao;
import com.op.studyingliteapp.sender.Runtime;
import com.op.studyingliteapp.sender.ui.view.device.DeviceScanDialog;
import com.op.util.ScreenSendUtils;

/**
 * @author handsome
 * @version 创建时间：2015年7月27日 下午10:28:28 类说明
 */
public class NotifDetailActivity extends ScreenshotActivity {
	private String getCourseUserId;
	private String  getCourseId;
	private DisplayImageOptions options;
//更改actionbar title

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_notif_detail);
       com.op.studyingliteapp.sender.Runtime.setView(findViewById(R.id.notif_detail_ll));
       ActionBar actionBar = getActionBar();
       actionBar.setDisplayHomeAsUpEnabled(true);
       actionBar.setDisplayShowHomeEnabled(false);
       actionBar.setDisplayShowTitleEnabled(true);
       actionBar.setTitle("通知");
		// 2. 设置option, 一般默认
		Intent intent = getIntent();
		
		options = new DisplayImageOptions.Builder()
		.showImageOnLoading(R.drawable.ic_stub)
		.showImageForEmptyUri(R.drawable.ic_empty)
		.showImageOnFail(R.drawable.ic_error).cacheInMemory(true)
		.cacheOnDisk(true).considerExifParams(true)
		.bitmapConfig(Bitmap.Config.RGB_565).build();

		SharedPreferences preferences = getSharedPreferences(
				"StudyingLite", Context.MODE_PRIVATE);
		getCourseUserId = preferences.getString(Common.Prefs.USER_ID, "");
		getCourseId = preferences.getString(Common.Prefs.COURSE_ID, "");

		ImageView imageView1 = (ImageView) findViewById(R.id.head_image);
		TextView name_tv1 = (TextView) findViewById(R.id.name_tv1);
		TextView time_tv1 = (TextView) findViewById(R.id.time_tv1);
		TextView title_tv1 = (TextView) findViewById(R.id.title_tv1);
		TextView detail_tv1 = (TextView) findViewById(R.id.detail_notif_tv);
		// Log.i("111", ""+context);
		CourseNotifDao courseNotifDao = new CourseNotifDao(this,
				getCourseUserId);
		List<CourseNotifBean> courseNotif = courseNotifDao
				.getNotifByCourseId(getCourseId);

		int position = intent.getIntExtra("position", 0);

		String title = courseNotif.get(position).getTitle();
		String time = courseNotif.get(position).getCreateTime();
		String context = courseNotif.get(position).getContent();
		String name = courseNotif.get(position).getUserBean().getName();
		String image = courseNotif.get(position).getUserBean().getImageUrl();
		//		 String courseNotifId = courseNotif.get(position).getId();

		// 个人信息头像设置
		ImageLoader.getInstance().displayImage(
				image, imageView1, options);
		name_tv1.setText(name);
		time_tv1.setText(time);
		title_tv1.setText(title);
		detail_tv1.setText(context);
	}

 

	
}